package com.huatai.bpmn.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huatai.bpmn.entity.YYExternalParameterEntity;
import com.huatai.bpmn.entity.YYExternalParameterEntity;
import com.huatai.bpmn.service.ExternalParameterService;
import com.huatai.bpmn.service.YYExternalParameterService;
import com.huatai.common.api.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  外部参数——表单关联
 * </p>
 *
 * @author yxy
 * @since 2023-08-14
 */
@RestController
@RequestMapping("/yyExternalParameterEntity")
@Api(value = "新-外部参数关联表",tags = "新-外部参数关联表")
public class YYExternalParameterController {

	@Autowired
	private YYExternalParameterService externalParameterService;

	@ApiOperation("数据列表（下拉）")
	@GetMapping("/list")
	public R list(){
		return R.data(externalParameterService.list());
	}

	@ApiOperation("数据列表（分页）")
	@GetMapping("/page")
	public R<Page<YYExternalParameterEntity>> page(@RequestParam("pageIndex")Integer pageIndex, @RequestParam("pageSize")Integer pageSize){
		Page<YYExternalParameterEntity> page = externalParameterService.page(pageIndex, pageSize);
		return R.data(page);
	}

	@ApiOperation("新增或修改，id为空新增，id不为空修改")
	@PostMapping("/saveOrUpdate")
	public R saveOrUpdate(@RequestBody YYExternalParameterEntity externalParameterEntity){
		return R.data(externalParameterService.saveOrUpdate(externalParameterEntity));
	}

	@ApiOperation("删除")
	@GetMapping("/delete")
	public R delete(@RequestParam("id")Long id){
		return R.data(externalParameterService.removeById(id));
	}

	@ApiOperation("根据id查询表头和外部参数")
	@GetMapping("/selectColumAndParamById")
	public R selectColumAndParamById(@RequestParam("id")Long id){
		return R.data(externalParameterService.selectColumAndParamById(id));
	}

	@GetMapping("/getDepartList")
	@ApiOperation("获取指定部门")
	public R getDepartList(){
		return R.data(externalParameterService.getDepartList());
	}

}

